<script setup>
import { reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { handleFeedback } from '@/service/feedback.js'
const feedbackInfo = reactive({})
const showModal = ref(false)
const notify = ref(false)
defineExpose({
  showModal,
  feedbackInfo,
})
const emits = defineEmits(['update'])
async function onTapSaveButton() {
  const params = {}
  console.log(feedbackInfo.status)
  params.feedbackId = feedbackInfo.id
  params.feedbackStatus = feedbackInfo.status
  params.remark = feedbackInfo.remark
  params.notify = notify.value
  console.log(params)
  await handleFeedback(params)
  ElMessage.success('成功处理该反馈！')
  showModal.value = false
  emits('update')
}
</script>

<template>
  <el-dialog destroy-on-close v-model="showModal" title="处理反馈" width="400">
    <el-form :model="feedbackInfo" label-position="top">
      <el-form-item label="处理状态:">
        <el-select v-model="feedbackInfo.status" placeholder="Select">
          <el-option label="未处理" :value="0" />
          <el-option label="已处理" :value="1" />
        </el-select>
      </el-form-item>
      <el-form-item label="处理备注:">
        <el-input
          v-model="feedbackInfo.remark"
          placeholder="请输入处理备注... "
          :autosize="{ minRows: 2, maxRows: 4 }"
          type="textarea"
        >
        </el-input>
      </el-form-item>
      <el-checkbox :disabled="feedbackInfo.status === 0" v-model="notify" label="通知用户处理结果" size="large" />
    </el-form>
    <template #footer>
      <el-button type="primary" @click="onTapSaveButton">保存</el-button>
      <el-button type="default" @click="showModal = false">取消</el-button>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss"></style>
